package com.briup.mt.service.impl;
import com.briup.mt.bean.BaseRole;
import com.briup.mt.bean.BaseRoleExample;
import com.briup.mt.dao.BaseRoleMapper;
import com.briup.mt.service.BaseRoleService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;
@Service
public class BaseRoleImpl implements BaseRoleService{

    @Resource
    private BaseRoleMapper baseRoleMapper;
    @Override
    public List<BaseRole>query(String name){
        BaseRoleExample baseRoleExample=new BaseRoleExample();
        if(!StringUtils.isEmpty(name)){
            baseRoleExample.createCriteria().andNameLike("%+name+%");
        }
        List<BaseRole> list=baseRoleMapper.selectByExample(baseRoleExample);
        return list;

    }

    @Override
    public void saveOrUpdate(BaseRole baseRole) {
        if (baseRole.getId()==null){
            baseRoleMapper.insert(baseRole);
        } else{
            baseRoleMapper.updateByPrimaryKey(baseRole);
        }
    }



    @Override
    public void deleteById(long id){
        baseRoleMapper.deleteByPrimaryKey(id);
    }
}